/******************************************************************************/
/* Filter Solutions Version 8.1                  Nuhertz Technologies, L.L.C. */
/*                                                            www.nuhertz.com */
/*                                                            +1 602-216-2682 */
/* 4th Order Low Pass Butterworth                                             */
/* Impulse Invariant Transformation                                           */
/* Sample Frequency = 2.000 KHz                                               */
/* Standard Form                                                              */
/* Arithmetic Precision = 4 Digits                                            */
/*                                                                            */
/* Pass Band Frequency = 25.00 Hz                                             */
/*                                                                            */
/******************************************************************************/
/*                                                                            */
/* Input Variable Definitions:                                                */
/* Inputs:                                                                    */
/*   invar    float       The input to the filter                             */
/*   initvar  float       The initial value of the filter                     */
/*   setic    int         1 to initialize the filter to the value of initvar  */
/*                                                                            */
/* There is no requirement to ever initialize the filter.                     */
/* The default initialization is zero when the filter is first called         */
/*                                                                            */
/******************************************************************************/
/*                                                                            */
/* This software is automatically generated by Filter Solutions.  There are   */
/* no restrictions from Nuhertz Technologies, L.L.C. regarding the use and    */
/* distributions of this software.                                            */
/*                                                                            */
/******************************************************************************/
//#include "my_type.h"
#include "stm32f4xx.h"

s32 DigFil_F(s32 invar , u8 mc_ch)
{
    int i;
    double sumnum, sumden;
    static int flag[2] = {0};
    static s64 delay[2][5];
    static float znum[4] = {
        0.0,
        3.234e-03,
        1.743e-02,
        5.982e-03
    };
    static float zden[4] = {
        .2919,
        -1.522,
        3.044,
        -2.787
    };

    if(flag[mc_ch] < 4)
    {
        delay[mc_ch][flag[mc_ch]++] = 154.8*invar;
        return invar;
    }

    sumden = 0;
    sumnum = 0;
    for (i = 0 ; i <= 3 ; i++)
    {
        delay[mc_ch][i] = delay[mc_ch][i+1];
        sumden += delay[mc_ch][i] * zden[i];
        sumnum += delay[mc_ch][i] * znum[i];
    }
    delay[mc_ch][4] = invar - sumden;
    return sumnum;
}

/********************** (C) COPYRIGHT 2013 InMotion *****END OF FILE************/ 
